package application.sudoku;

import java.io.File;
import java.io.IOException;
import java.util.*;

public class Sudoku {
    public char[][] board;
    public Sudoku(char[][] board) {
        int row = board.length;
        int col = board[0].length;
        if (row != 9 || col != 9) {
            return;
        }
        this.board = new char[9][9];
        for (int i = 0; i < 9; ++i) {
            for (int j = 0; j < 9; ++j) {
                this.board[i][j] = board[i][j];
            }
        }
    }
    public Sudoku(String filename) {
        this.board = new char[9][9];
        File file = new File(filename);
        try (Scanner scanner = new Scanner(file)) {
            for (int i = 0; i < 9; ++i) {
                String line = scanner.next();
                for (int j = 0; j < 9; ++j) {
                    this.board[i][j] = line.charAt(j);
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public String toString() {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 9; ++i) {
            for (int j = 0; j < 9; ++j) {
                sb.append(this.board[i][j]).append("  ");
            }
            sb.append('\n');
        }
        return sb.toString();
    }
}
